package order;

import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;

import basket.BasketVO;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

public class OrderAction extends ActionSupport 
implements Preparable, ModelDriven{
	
	  private OrderVO order;
	  private List<OrderVO> basketlist;
	  private List<OrderVO> senderlist;
	  private int count = 0;
	 
	  public String execute() throws Exception{
		
	   Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
	   SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
	   reader.close();
	   
	   basketlist=sqlMap.queryForList("selectbasketlist",order);
	   senderlist=sqlMap.queryForList("selectsenderlist",order);
	  
	   count = basketlist.size();
	   
	   return SUCCESS;
	   
  }
		/*public String orderAdd() throws Exception{
		
		Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
		SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		reader.close();
		
	    sqlMap.insert("insertAdd", order);
		
		return SUCCESS;
		
	}*/

	@Override
	public void prepare() throws Exception {
		order = new OrderVO();
		
	}

	@Override
	public Object getModel() {
		return order;
		
	}

	public List<OrderVO> getBasketlist() {
		return basketlist;
	}

	public void setBasketlist(List<OrderVO> basketlist) {
		this.basketlist = basketlist;
	}

	public List<OrderVO> getSenderlist() {
		return senderlist;
	}

	public void setSenderlist(List<OrderVO> senderlist) {
		this.senderlist = senderlist;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}
}
